package com.fjs.pojo;

import java.io.FileWriter;
import java.io.IOException;


public class Customer extends Thread{
    @Override
    public void run() {
        for (int i = 1;i<10000000;i++){
            Bank.add(100);
        }
    }

    public static void main(String[] args) throws IOException {

        FileWriter fileWriter = new FileWriter("filt.txt",true);

        //Customer customer = new Customer();
        //Thread thread = new Thread(customer,"顾客1");
        //Thread thread2 = new Thread(customer,"顾客2");
        //thread.start();
        //thread2.start();
        //System.out.println("---------------");
        Customer customer3 = new Customer();
        Customer customer2 = new Customer();
        customer3.start();
        customer2.start();
    }
}

class Bank{
    public static int sum = 0;
    public static void add(int n){
        int tmp = sum ;
        tmp = tmp+n;
        try {
            //Thread.sleep((int)(1000*Math.random()));
            Thread.sleep(1);
            sum = tmp;
            System.out.println(Thread.currentThread().getName()+"sum="+sum);
            //System.out.println("sum="+sum);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
